<?php
/**
 * ActionModel.class.php
 * 动作模型
 * 
 * @author 	王中艺	<wangzy_smile@qq.com>
 * @date 	2017-05-04
 */

namespace Wechat\Model;

class ActionModel extends BaseModel {

	//重定义数据表名
	protected 	$trueTableName = 't_action_log';

	/**
	 * 添加动作记录
	 * @param 	$userId		用户ID
	 * @param 	$relateType 动作类型
	 * @param 	$relateId	关联ID
	 * @param 	$remark 	备注json
	 * @return 	boolean
	 */
	function addItem($userId, $relateType, $relateId, $remark = ''){
		$log 	= [
			'user_id' 	=> $userId,
			'relate_type'	=> $relateType,
			'relate_id'	=> $relateId,
			'create_time' 	=> time(),
			'remark' 	=> json_encode($remark)
		];

		$result 	= $this->add($log);
		if(!$result){
			$this->errMsg 	= '记录添加失败!';
			return false;
		}

		return true;
	}
}